|
1
|
|
|
/*! |
|
2
|
|
|
* Bootstrap button.js v4.3.1 (https://getbootstrap.com/) |
|
3
|
|
|
* Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) |
|
4
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
|
5
|
|
|
*/ |
|
6
|
|
|
(function (global, factory) { |
|
7
|
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery')) : |
|
8
|
|
|
typeof define === 'function' && define.amd ? define(['jquery'], factory) : |
|
|
|
|
|
|
9
|
|
|
(global = global || self, global.Button = factory(global.jQuery)); |
|
|
|
|
|
|
10
|
|
|
}(this, function ($) { 'use strict'; |
|
11
|
|
|
|
|
12
|
|
|
$ = $ && $.hasOwnProperty('default') ? $['default'] : $; |
|
13
|
|
|
|
|
14
|
|
|
function _defineProperties(target, props) { |
|
15
|
|
|
for (var i = 0; i < props.length; i++) { |
|
16
|
|
|
var descriptor = props[i]; |
|
17
|
|
|
descriptor.enumerable = descriptor.enumerable || false; |
|
18
|
|
|
descriptor.configurable = true; |
|
19
|
|
|
if ("value" in descriptor) descriptor.writable = true; |
|
|
|
|
|
|
20
|
|
|
Object.defineProperty(target, descriptor.key, descriptor); |
|
21
|
|
|
} |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
function _createClass(Constructor, protoProps, staticProps) { |
|
25
|
|
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
|
|
|
|
|
26
|
|
|
if (staticProps) _defineProperties(Constructor, staticProps); |
|
|
|
|
|
|
27
|
|
|
return Constructor; |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* ------------------------------------------------------------------------ |
|
32
|
|
|
* Constants |
|
33
|
|
|
* ------------------------------------------------------------------------ |
|
34
|
|
|
*/ |
|
35
|
|
|
|
|
36
|
|
|
var NAME = 'button'; |
|
37
|
|
|
var VERSION = '4.3.1'; |
|
38
|
|
|
var DATA_KEY = 'bs.button'; |
|
39
|
|
|
var EVENT_KEY = "." + DATA_KEY; |
|
40
|
|
|
var DATA_API_KEY = '.data-api'; |
|
41
|
|
|
var JQUERY_NO_CONFLICT = $.fn[NAME]; |
|
42
|
|
|
var ClassName = { |
|
43
|
|
|
ACTIVE: 'active', |
|
44
|
|
|
BUTTON: 'btn', |
|
45
|
|
|
FOCUS: 'focus' |
|
46
|
|
|
}; |
|
47
|
|
|
var Selector = { |
|
48
|
|
|
DATA_TOGGLE_CARROT: '[data-toggle^="button"]', |
|
49
|
|
|
DATA_TOGGLE: '[data-toggle="buttons"]', |
|
50
|
|
|
INPUT: 'input:not([type="hidden"])', |
|
51
|
|
|
ACTIVE: '.active', |
|
52
|
|
|
BUTTON: '.btn' |
|
53
|
|
|
}; |
|
54
|
|
|
var Event = { |
|
55
|
|
|
CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY, |
|
56
|
|
|
FOCUS_BLUR_DATA_API: "focus" + EVENT_KEY + DATA_API_KEY + " " + ("blur" + EVENT_KEY + DATA_API_KEY) |
|
57
|
|
|
/** |
|
58
|
|
|
* ------------------------------------------------------------------------ |
|
59
|
|
|
* Class Definition |
|
60
|
|
|
* ------------------------------------------------------------------------ |
|
61
|
|
|
*/ |
|
62
|
|
|
|
|
63
|
|
|
}; |
|
64
|
|
|
|
|
65
|
|
|
var Button = |
|
66
|
|
|
/*#__PURE__*/ |
|
67
|
|
|
function () { |
|
68
|
|
|
function Button(element) { |
|
69
|
|
|
this._element = element; |
|
70
|
|
|
} // Getters |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
var _proto = Button.prototype; |
|
74
|
|
|
|
|
75
|
|
|
// Public |
|
76
|
|
|
_proto.toggle = function toggle() { |
|
77
|
|
|
var triggerChangeEvent = true; |
|
78
|
|
|
var addAriaPressed = true; |
|
79
|
|
|
var rootElement = $(this._element).closest(Selector.DATA_TOGGLE)[0]; |
|
80
|
|
|
|
|
81
|
|
|
if (rootElement) { |
|
82
|
|
|
var input = this._element.querySelector(Selector.INPUT); |
|
83
|
|
|
|
|
84
|
|
|
if (input) { |
|
85
|
|
|
if (input.type === 'radio') { |
|
86
|
|
|
if (input.checked && this._element.classList.contains(ClassName.ACTIVE)) { |
|
87
|
|
|
triggerChangeEvent = false; |
|
88
|
|
|
} else { |
|
89
|
|
|
var activeElement = rootElement.querySelector(Selector.ACTIVE); |
|
90
|
|
|
|
|
91
|
|
|
if (activeElement) { |
|
92
|
|
|
$(activeElement).removeClass(ClassName.ACTIVE); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
if (triggerChangeEvent) { |
|
98
|
|
|
if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains('disabled') || rootElement.classList.contains('disabled')) { |
|
99
|
|
|
return; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
input.checked = !this._element.classList.contains(ClassName.ACTIVE); |
|
103
|
|
|
$(input).trigger('change'); |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
input.focus(); |
|
107
|
|
|
addAriaPressed = false; |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
if (addAriaPressed) { |
|
112
|
|
|
this._element.setAttribute('aria-pressed', !this._element.classList.contains(ClassName.ACTIVE)); |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
if (triggerChangeEvent) { |
|
116
|
|
|
$(this._element).toggleClass(ClassName.ACTIVE); |
|
117
|
|
|
} |
|
118
|
|
|
}; |
|
119
|
|
|
|
|
120
|
|
|
_proto.dispose = function dispose() { |
|
121
|
|
|
$.removeData(this._element, DATA_KEY); |
|
122
|
|
|
this._element = null; |
|
123
|
|
|
} // Static |
|
124
|
|
|
; |
|
125
|
|
|
|
|
126
|
|
|
Button._jQueryInterface = function _jQueryInterface(config) { |
|
127
|
|
|
return this.each(function () { |
|
128
|
|
|
var data = $(this).data(DATA_KEY); |
|
129
|
|
|
|
|
130
|
|
|
if (!data) { |
|
131
|
|
|
data = new Button(this); |
|
132
|
|
|
$(this).data(DATA_KEY, data); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
if (config === 'toggle') { |
|
136
|
|
|
data[config](); |
|
137
|
|
|
} |
|
138
|
|
|
}); |
|
139
|
|
|
}; |
|
140
|
|
|
|
|
141
|
|
|
_createClass(Button, null, [{ |
|
142
|
|
|
key: "VERSION", |
|
143
|
|
|
get: function get() { |
|
144
|
|
|
return VERSION; |
|
145
|
|
|
} |
|
146
|
|
|
}]); |
|
147
|
|
|
|
|
148
|
|
|
return Button; |
|
149
|
|
|
}(); |
|
150
|
|
|
/** |
|
151
|
|
|
* ------------------------------------------------------------------------ |
|
152
|
|
|
* Data Api implementation |
|
153
|
|
|
* ------------------------------------------------------------------------ |
|
154
|
|
|
*/ |
|
155
|
|
|
|
|
156
|
|
|
|
|
157
|
|
|
$(document).on(Event.CLICK_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { |
|
158
|
|
|
event.preventDefault(); |
|
159
|
|
|
var button = event.target; |
|
160
|
|
|
|
|
161
|
|
|
if (!$(button).hasClass(ClassName.BUTTON)) { |
|
162
|
|
|
button = $(button).closest(Selector.BUTTON); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
Button._jQueryInterface.call($(button), 'toggle'); |
|
166
|
|
|
}).on(Event.FOCUS_BLUR_DATA_API, Selector.DATA_TOGGLE_CARROT, function (event) { |
|
167
|
|
|
var button = $(event.target).closest(Selector.BUTTON)[0]; |
|
168
|
|
|
$(button).toggleClass(ClassName.FOCUS, /^focus(in)?$/.test(event.type)); |
|
169
|
|
|
}); |
|
170
|
|
|
/** |
|
171
|
|
|
* ------------------------------------------------------------------------ |
|
172
|
|
|
* jQuery |
|
173
|
|
|
* ------------------------------------------------------------------------ |
|
174
|
|
|
*/ |
|
175
|
|
|
|
|
176
|
|
|
$.fn[NAME] = Button._jQueryInterface; |
|
177
|
|
|
$.fn[NAME].Constructor = Button; |
|
178
|
|
|
|
|
179
|
|
|
$.fn[NAME].noConflict = function () { |
|
180
|
|
|
$.fn[NAME] = JQUERY_NO_CONFLICT; |
|
181
|
|
|
return Button._jQueryInterface; |
|
182
|
|
|
}; |
|
183
|
|
|
|
|
184
|
|
|
return Button; |
|
185
|
|
|
|
|
186
|
|
|
})); |
|
187
|
|
|
//# sourceMappingURL=button.js.map |
|
188
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.